import React, { Component } from 'react'

export default class Order extends Component {
  constructor() {
    super()
    this.state = {
      myList: [
        {name: 'orange', id: 3},
        {name: 'prach', id: 4}
      ]
    }
  }
  render() {
    let {list, addList} = this.props
    return (
      <div>
        <div>我是子组件-order</div>
        <div>订单列表</div>
        {
          list.map(item => {
            return (
              <div key={item.id}>{item.name}</div>
            )
          })
        }
        <p>待添加：</p>
        {
          this.state.myList.map((itme, index) => {
            return (
              <div key={index}>
                <span>{itme.name}</span>
                <button onClick={()=>addList(itme)}>add</button>
              </div>
            )
          })
        }
      </div>
    )
  }
}
